//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995-1999  Microsoft Corporation

Module Name:

smscmn.h

Abstract:


Notes:


--*/


#pragma once



#define MAX_MSGBUFFER 1024

#if 1 //#ifdef WAVECOM_SERIES2_DRIVER
// HW-SPECIFIC: WaveCom Series 2 hardware doesn't encode the SMSC address prepended to a message
#define WAVECOM_SERIES2_DRIVER_BOGUS_ADDR_LENGTH    12
#endif // WAVECOM_SERIES2_DRIVER


//
// Address types
//
static const BYTE g_rgbAddrTypes[] =
{
    0x00,   // RIL_ADDRTYPE_UNKNOWN
    0x01,   // RIL_ADDRTYPE_INTERNATIONAL
    0x02,   // RIL_ADDRTYPE_NATIONAL
    0x03,   // RIL_ADDRTYPE_NETWKSPECIFIC
    0x04,   // RIL_ADDRTYPE_SUBSCRIBER
    0x05,   // RIL_ADDRTYPE_ALPHANUM
    0x06,   // RIL_ADDRTYPE_ABBREV
};
#define NUM_ADDRTYPES   (sizeof(g_rgbNumPlans) / sizeof(BYTE))


//
// Numbering plans
//
static const BYTE g_rgbNumPlans[] =
{
    0x00,   // RIL_NUMPLAN_UNKNOWN
    0x01,   // RIL_NUMPLAN_TELEPHONE
    0x03,   // RIL_NUMPLAN_DATA
    0x04,   // RIL_NUMPLAN_TELEX
    0x08,   // RIL_NUMPLAN_NATIONAL
    0x09,   // RIL_NUMPLAN_PRIVATE
    0x0a,   // RIL_NUMPLAN_ERMES
};
#define NUM_NUMPLANS   (sizeof(g_rgbNumPlans) / sizeof(BYTE))


//
// ProtocolID types
//
static const DWORD g_rgdwProtocolIDs[] =
{
    0x00,   // RIL_MSGPROTOCOL_UNKNOWN
    0x00,   // RIL_MSGPROTOCOL_SMETOSME
    0x20,   // RIL_MSGPROTOCOL_IMPLICIT
    0x21,   // RIL_MSGPROTOCOL_TELEX
    0x22,   // RIL_MSGPROTOCOL_TELEFAX_GROUP3
    0x23,   // RIL_MSGPROTOCOL_TELEFAX_GROUP4
    0x24,   // RIL_MSGPROTOCOL_VOICEPHONE
    0x25,   // RIL_MSGPROTOCOL_ERMES
    0x26,   // RIL_MSGPROTOCOL_PAGING
    0x27,   // RIL_MSGPROTOCOL_VIDEOTEX
    0x28,   // RIL_MSGPROTOCOL_TELETEX
    0x29,   // RIL_MSGPROTOCOL_TELETEX_PSPDN
    0x2a,   // RIL_MSGPROTOCOL_TELETEX_CSPDN
    0x2b,   // RIL_MSGPROTOCOL_TELETEX_PSTN
    0x2c,   // RIL_MSGPROTOCOL_TELETEX_ISDN
    0x2d,   // RIL_MSGPROTOCOL_UCI
    0x30,   // RIL_MSGPROTOCOL_MSGHANDLING
    0x31,   // RIL_MSGPROTOCOL_X400
    0x32,   // RIL_MSGPROTOCOL_EMAIL
    0x38,   // RIL_MSGPROTOCOL_SCSPECIFIC1
    0x39,   // RIL_MSGPROTOCOL_SCSPECIFIC2
    0x3a,   // RIL_MSGPROTOCOL_SCSPECIFIC3
    0x3b,   // RIL_MSGPROTOCOL_SCSPECIFIC4
    0x3c,   // RIL_MSGPROTOCOL_SCSPECIFIC5
    0x3d,   // RIL_MSGPROTOCOL_SCSPECIFIC6
    0x3e,   // RIL_MSGPROTOCOL_SCSPECIFIC7
    0x3f,   // RIL_MSGPROTOCOL_GSMSTATION
    0x40,   // RIL_MSGPROTOCOL_SM_TYPE0
    0x41,   // RIL_MSGPROTOCOL_RSM_TYPE1
    0x42,   // RIL_MSGPROTOCOL_RSM_TYPE2
    0x43,   // RIL_MSGPROTOCOL_RSM_TYPE3
    0x44,   // RIL_MSGPROTOCOL_RSM_TYPE4
    0x45,   // RIL_MSGPROTOCOL_RSM_TYPE5
    0x46,   // RIL_MSGPROTOCOL_RSM_TYPE6
    0x47,   // RIL_MSGPROTOCOL_RSM_TYPE7
    0x5f,   // RIL_MSGPROTOCOL_RETURNCALL
    0x7d,   // RIL_MSGPROTOCOL_ME_DOWNLOAD
    0x7e,   // RIL_MSGPROTOCOL_DEPERSONALIZATION
    0x7f,   // RIL_MSGPROTOCOL_SIM_DOWNLOAD
};
#define NUM_PROTOCOLIDS (sizeof(g_rgdwProtocolIDs) / sizeof(DWORD))


//
// Status-Report values
//
static const DWORD g_rgdwDlvStatus[] =
{
    0xff,   // UNUSED
    0x00,   // RIL_MSGDLVSTATUS_RECEIVEDBYSME
    0x01,   // RIL_MSGDLVSTATUS_FORWARDEDTOSME
    0x02,   // RIL_MSGDLVSTATUS_REPLACEDBYSC
    0x20,   // RIL_MSGDLVSTATUS_CONGESTION_TRYING
    0x21,   // RIL_MSGDLVSTATUS_SMEBUSY_TRYING
    0x22,   // RIL_MSGDLVSTATUS_SMENOTRESPONDING_TRYING
    0x23,   // RIL_MSGDLVSTATUS_SVCREJECTED_TRYING
    0x24,   // RIL_MSGDLVSTATUS_QUALITYUNAVAIL_TRYING
    0x25,   // RIL_MSGDLVSTATUS_SMEERROR_TRYING
    0x60,   // RIL_MSGDLVSTATUS_CONGESTION
    0x61,   // RIL_MSGDLVSTATUS_SMEBUSY
    0x62,   // RIL_MSGDLVSTATUS_SMENOTRESPONDING
    0x63,   // RIL_MSGDLVSTATUS_SVCREJECTED
    0x64,   // RIL_MSGDLVSTATUS_QUALITYUNAVAIL_TEMP
    0x65,   // RIL_MSGDLVSTATUS_SMEERROR
    0x40,   // RIL_MSGDLVSTATUS_REMOTEPROCERROR
    0x41,   // RIL_MSGDLVSTATUS_INCOMPATIBLEDEST
    0x42,   // RIL_MSGDLVSTATUS_CONNECTIONREJECTED
    0x43,   // RIL_MSGDLVSTATUS_NOTOBTAINABLE
    0x44,   // RIL_MSGDLVSTATUS_QUALITYUNAVAIL
    0x45,   // RIL_MSGDLVSTATUS_NOINTERNETWORKING
    0x46,   // RIL_MSGDLVSTATUS_VPEXPIRED
    0x47,   // RIL_MSGDLVSTATUS_DELETEDBYORIGSME
    0x48,   // RIL_MSGDLVSTATUS_DELETEDBYSC
    0x49,   // RIL_MSGDLVSTATUS_NOLONGEREXISTS
};
#define NUM_DLVSTATUS   (sizeof(g_rgdwDlvStatus) / sizeof(DWORD))


//
// Unified FILETIME-ULARGE_INTEGER struct
//
struct FILETIME_ULARGEINT {
    union {
        FILETIME ft;
        ULARGE_INTEGER uli;
    };
};


HRESULT ParseCellBroadcastMessage(const LPCSTR sIn, const UINT cbIn, RILMESSAGE& rrmMsg);
HRESULT ParseSMSMessage(const LPCSTR sIn, const UINT cbIn, BOOL fIncoming, BOOL fPrependedSMSC, RILMESSAGE& rrmMsg);
HRESULT EncodeSMSMessage(const RILMESSAGE& rmMsg, const LPSTR sOut, const UINT cbOut, UINT& rcbUsed,
                         UINT& rnGSMLength);


